clear
set more off
import excel "\\file\UsersW$\wrr15\Home\My Documents\My Files\CLASSES\ECON 324 (2020)\Week8\wagepan.xls", sheet("Sheet1") firstrow
global vars1 educ black hisp exper expersq married union d81 d82 d83 d84 d85 d86 d87
global vars2 educ black hisp exper married union
xtset nr year
xtreg lwage $vars1 , fe
gen insample = e(sample)
drop if insample == 0

foreach i in $vars1  {  
bysort nr: egen mean`i' = mean(`i')
}

mixed lwage $vars1 mean* || nr:

xttab married
xttrans married

xtset nr year
foreach i in $vars2   {  
bysort nr: egen `i'min = min(`i')
bysort nr: egen `i'max = max(`i')
gen  change`i' = `i'max - `i'min
replace change`i' = (change`i' > 0)
}

collapse (mean) change* , by(nr)
summ change*

